package br.ucb.cm.config.bean;
import java.io.Serializable;

import br.ucb.cm.board.util.ImageEnum;

public class PieceConfig implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private String name;
	private Integer points;
	private Movimentation moves;
	private Movimentation attack;
	private ImageEnum icon;
	
	public PieceConfig(String name){
		this.name = name;
	}
	
	public PieceConfig(ImageEnum imageEnum){
		this.icon = imageEnum;
	}
	
	public PieceConfig(String name, Integer points, Movimentation moves,
			Movimentation attack, ImageEnum icon) {
		this.name = name;
		this.points = points;
		this.moves = moves;
		this.attack = attack;
		this.icon = icon;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getPoints() {
		return points;
	}
	public void setPoints(Integer points) {
		this.points = points;
	}
	public Movimentation getMoves() {
		return moves;
	}
	public void setMoves(Movimentation moves) {
		this.moves = moves;
	}
	public Movimentation getAttack() {
		return attack;
	}
	public void setAttack(Movimentation attack) {
		this.attack = attack;
	}
	public ImageEnum getIcon() {
		return icon;
	}
	public void setIcon(ImageEnum icon) {
		this.icon = icon;
	}
	
	@Override
	public String toString() {
		return "Piece [name=" + name + ", points=" + points + ", moves="
				+ moves + ", attack=" + attack + ", icon=" + icon + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((attack == null) ? 0 : attack.hashCode());
		result = prime * result + ((icon == null) ? 0 : icon.hashCode());
		result = prime * result + ((moves == null) ? 0 : moves.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((points == null) ? 0 : points.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		PieceConfig other = (PieceConfig) obj;
		
		if (name != null && name.equalsIgnoreCase(other.name))
			return true;
		if (attack != null && attack.equals(other.attack) && moves.equals(other.moves))
			return true;
		if (icon != null && icon.equals(other.icon))
			return true;
		
		return false;
	}
	
}
